package com.ccut.lc.service.Impl;

import com.ccut.lc.dao.ProductTypeMapper;
import com.ccut.lc.model.ProductType;
import com.ccut.lc.model.QueryVo;
import com.ccut.lc.service.ProductTypeService;
import com.ccut.lc.utils.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ProductTypeServiceImpl implements ProductTypeService {
    @Resource
    private ProductTypeMapper productTypeMapper;
    @Override
    public Page<ProductType> selProductType(QueryVo queryVo) {
        queryVo.setStart((queryVo.getPage()-1)*queryVo.getRows());
        List<ProductType> list = productTypeMapper.selProductType(queryVo);
        int total = productTypeMapper.getTotal(queryVo);
        Page<ProductType> page = new Page<>(total,queryVo.getPage(),queryVo.getRows(),list);
        return page;
    }

    @Override
    public int getTotal(QueryVo queryVo) {
        return 0;
    }

    @Override
    public void deleteProductType(Integer id) {
        productTypeMapper.deleteProductType(id);
    }

    @Override
    public ProductType findProductTypeByID(Integer id) {
        return  productTypeMapper.findProductTypeByID(id);
    }

    @Override
    public void addProduct(ProductType productType) {
        productTypeMapper.addProduct(productType);
    }

    @Override
    public void updateProductType(ProductType productType) {
        productTypeMapper.updateProductType(productType);
    }
}
